home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
mc51bugs.zip
/
Q29850
< prev
next >
Wrap
Text File
|
1988-07-21
|
1KB
|
51 lines
Q29850 Bad Code Generation with Call to Function
C Compiler
5.00 5.10
MS-DOS
Problem:
The compiler generates incorrect code for a call to the function
strcpy() in the following program when it is compiled in small or
medium model. When the compiler makes the following call:
strcpy(macronames[nrmacros],line);
the generated code pushes macrobuffer+totalmac instead of pushing
macronames[nrmacros]. The example follows:
#include <stdio.h>
#include <string.h>
int nrmacros=0;
char macrobuffer[800],*macronames[10];
int l;
void openfiles()
{
char line[128];
int totalmac;
char *macropointer =macrobuffer;
macropointer=macrobuffer+totalmac;
macronames[nrmacros]=macropointer;
totalmac += l-1;
if(totalmac<=800)
strcpy(macronames[nrmacros],line);
}
Response:
The code that is generated is seeing the following:
macronames[nrmacros] = macropointer=macrobuffer+totalmac;
However, by the time the call to strcpy() is made, this equivalence
is no longer true because the value of the variable totalmac has
changed. You can work around the problem by making the call to strcpy
as follows:
strcpy(macropointer,line);
Microsoft is researching this problem and will post new information
as it becomes available.
Keywords: buglist5.00 buglist5.10 TAR76363
Updated 88/07/21 03:19